<template>
	<view class="bottom-action" @touchmove.stop.prevent="stopTouchMove">
		<view class="actions">
			<view class="action-item">
				<icon class="iconfont icon-like" />
				<view class="like-text">点赞</view>
			</view>
			<view class="action-item" @tap="showCommentBox">
				<icon class="iconfont icon-comment" />
				<view class="like-text">回复</view>
			</view>
			<view class="action-item">
				<icon class="uni-icon-starhalf" />
				<view class="like-text">分享</view>
			</view>
		</view>
		<view class="comment-box" :class="{'comment-box-show': shouldShowCommentBox}">
			<view class="mask" @tap="hideCommentBox"></view>
			<view class="solid" :style="{transform: transformValue}">
				<view class="textarea-wrap">
					<textarea class="textarea" auto-height="true" maxlength="200" :focus="focus" cursor-spacing="400upx" :fixed="true"></textarea>
				</view>
				<view class="other">
					<view class="btn-advance-mode">高级模式</view>
				</view>
				<view><button type="primary" class="btn-submit">发布</button></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				commentBoxHeight: "0",
				maskBackgroundColor: "rgba(#000, 0.2)",
				commentSolidHeight: "0",
				focus: false,
				shouldShowCommentBox: false,
				transformValue: "translateY(0)"
			};
		},
		created() {
			uni.onKeyboardHeightChange((res) => {
				console.log('onKeyboardHeightChange', res)
				// this.transformValue = "translateY(-" + res.height/2 + "px)";
			})
		},
		methods: {
			stopTouchMove(e) {
				console.log(e);
				return false;
			},
			hideCommentBox() {
				this.shouldShowCommentBox = false;
			},
			showCommentBox() {
				this.shouldShowCommentBox = true;
			}
		}
	}
</script>

<style lang="scss">
.bottom-action {
	.actions {
		position: fixed;
		bottom: 0;
		width: 100%;
		padding: 16upx 0;
		background-color: #fff;
		display: flex;
		.action-item {
			display: flex;
			flex-grow: 1;
			justify-content: center;
			align-items: center;
		}
	}
	.comment-box {
		z-index: 999;
		position: fixed;
		width: 100%;
		height: 100vh;
		display: none;
		left: 0;
		right: 0;
		bottom: 0;
		flex-direction: column;
		justify-content: space-between;
		transition-duration: 0.5s;
		.mask {
			flex-grow: 1;
			background-color: rgba($color: #000000, $alpha: 0.2);
		}
		.solid {
			background-color: #fff;
			.textarea-wrap {
				padding: 30upx 30upx 0;
				.textarea {
					width: 100%;
					min-height: 300upx;
					border: 1px solid #ddd;
					padding: 20upx;
					box-sizing: border-box;
				}
			}
			.other {
				padding: 30upx;
				text-align: right;
				.btn-advance-mode {
					display: inline;
					padding: 8upx 20upx;
					background-color: #ddd;
				}
			}
			.btn-submit {
				border-radius: 0;
			}
		}
		
	}
	.comment-box-show {
		top: var(--window-top) !important;
		height: calc(100vh - var(--window-top));
		display: flex;
	}
}
</style>
